<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants"%>
<%@ page import="com.scalar.chiptrack.users.Functionality"%>
<%@ page import="com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/operationsDataDumpReports.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%String reportType = (String)request.getAttribute("reportType");%>
<%
    String transactionReportType = Constants.ACTION_DATA_DUMP_TRANSACTION_REPORT;
    String sortTransactionReportType = Constants.ACTION_SORT_TRANSACTION_DATA_DUMP_REPORT;
    String AssmTransactionReportType = Constants.ACTION_ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT;
%>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>
<SCRIPT language="JavaScript">
    function exportToFile(reportType)
    {
        var errors1 = "";
        var fromDate = dataDumpReportsForm.fromDate;
        var toDate   = dataDumpReportsForm.toDate;
        var transactionReportType = '<%=transactionReportType%>';
        var sortTransactionReportType = '<%=sortTransactionReportType%>';
        var AssmTransactionReportType = '<%=AssmTransactionReportType%>';
        document.getElementById("errors1").innerHTML='';
        if( reportType == transactionReportType || reportType == sortTransactionReportType || reportType == AssmTransactionReportType )
        {
            if( trim(fromDate.value) == '' )
            {
                errors1 = errors1 +'<br>' + "<li> Please Enter From Date";
                fromDate.focus();
            }
        }
        if( chkDate(fromDate.value,"From Date","N") == false) {
            errors1 = errors1 +'<br>' + errMsg;
            fromDate.select();
            fromDate.focus();
        }
        else if( chkDate(toDate.value,"To Date","N") == false) {
            errors1 = errors1 +'<br>' + errMsg;
            toDate.select();
            toDate.focus();
        }
        else if ( fromDate.value != '' && toDate.value != ''  && CompareDate( fromDate.value, toDate.value ) == false )
        {
            errors1 = errors1 +'<br>' + "<li> To Date cannot be less than From Date";
            toDate.select();
            toDate.focus();
        }
        if ( errors1 == "" )
        {
            reportType = '<%=reportType%>';
            from = dataDumpReportsForm.fromDate.value;
            to = dataDumpReportsForm.toDate.value;
            var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=' + reportType+'&popUp=true&from='+from+'&to='+to;
            newWindow = window.open ( url,reportType,'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else
        {
            var pa = document.getElementById("errors1");
            pa.innerHTML = errors1;
        }
    }
    function clearErrors()
    {
        var pa=document.getElementById("errors");
        pa.innerHTML = "";
    }
    function openCalendar(dateValue)
    {
        dateElement = dateValue;

        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }
    function assignDate( passedValue )
    {
        dateElement.value = passedValue;
        window.focus();
    }
</SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" >

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

    <!-- Side Navigation start -->
    <%@ include file="/jsp/operations/dump_reports_side_menu.jsp" %></TD>
    <!-- end of the side navigations -->

    <TD bgcolor="#ffffff">
    <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
    <TD valign="top" width="100%">

    <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
    <BR>

   	<html:form name="dataDumpReportsForm" action="/operationsDataDumpReports" method="POST" enctype="multipart/form-data" type="com.scalar.chiptrack.operations.reports.forms.DataDumpReportsForm" scope="request">
        <input type="hidden" name="action" value="">
        <TABLE width='95%' align=right cellpadding='0' cellspacing='0' border='0'>
            <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_SORT_REPORT%>">
                <TR><Td class="NArialW" align=center>Sort Data Dump Report</td></tr>
            </logic:equal>
            <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_ASSEMBLY_REPORT%>">
                <TR><Td class="NArialW" align=center>Assembly Data Dump Report</td></tr>
            </logic:equal>
            <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_TRANSACTION_REPORT%>">
                <TR><Td class="NArialW" align=center>Transaction Data Dump Report</td></tr>
            </logic:equal>
            <logic:equal name="reportType" value="<%=Constants.ACTION_SORT_TRANSACTION_DATA_DUMP_REPORT%>">
                <TR><Td class="NArialW" align=center>Sort Transaction Data Dump Report</td></tr>
            </logic:equal>
            <logic:equal name="reportType" value="<%=Constants.ACTION_ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT%>">
                <TR><Td class="NArialW" align=center>Assembly Transaction Data Dump Report</td></tr>
            </logic:equal>
            <TR><TD><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr><td align="left" class='NArialL'>&nbsp;<FONT id="errors1" color='FF0000'></font></td></tr>
            <TR><TD><chiptrack:errors styleClass="NArialL"/><chiptrack:info styleClass="NArialL"/></TD></TR>
             <logic:equal name="showMessage" value="TRUE">
                <TR><TD><FONT class='NArialS'color='blue'><B><%=Constants.NO_MODIFY_RIGHTS %></B></FONT></TD></TR>
            </logic:equal>
            <TR><TD><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>

            <TR>
                <TD width="100%" align="center">
                    <TABLE border="0" width="75%">
                        <TR>
                            <TD class="NArialL" width="18%"> From Date :
                            <%
                                if( Constants.ACTION_DATA_DUMP_TRANSACTION_REPORT.equalsIgnoreCase(reportType) ||
                                    Constants.ACTION_SORT_TRANSACTION_DATA_DUMP_REPORT.equalsIgnoreCase(reportType) ||
                                    Constants.ACTION_ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT.equalsIgnoreCase(reportType) )
                                {
                            %>
                                <font color="RED" size="1"><B> *</B></font>
                            <%
                                }
                            %>
                            </TD>
                            <TD class="NArialL" width='30%' align="left">
                                <html:text property="fromDate" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.dataDumpReportsForm.fromDate )"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20 title="Click here to select date"></a>
                            </TD>
                            <TD width="5%">&nbsp;</TD>
                            <TD class="NArialL" width="17%"> To Date :</TD>
                            <TD class="NArialL" width='30%'  align="left">
                                <html:text property="toDate" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.dataDumpReportsForm.toDate )"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20 title="Click here to select date"></a>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
			</TR>
            <TR><TD>&nbsp;</TD></TR>
            <TR><TD>&nbsp;</TD></TR>
            <tr>
                <TD width="100%" align="center">
                    <TABLE width="75%">
                        <td width="100%" align=center>
                        <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_SORT_REPORT%>">
                            <chiptrack:restrictedLink functionality='<%=Functionality.SORT_DATA_DUMP_REPORT%>' action='<%=User.USER_ACTION_VIEW%>' href='javascript:exportToFile();' onmouseover="window.status='Click here to export to excel file';return true" onmouseout="window.status='';return true">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" ALIGN="BOTTOM" BORDER="0"  width="53" height="17" title="Click here to export to excel file"/>
                            </chiptrack:restrictedLink>
                        </logic:equal>
                        <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_ASSEMBLY_REPORT%>">
                            <chiptrack:restrictedLink functionality='<%=Functionality.ASSEMBLY_DATA_DUMP_REPORT%>' action='<%=User.USER_ACTION_VIEW%>' href='javascript:exportToFile();' onmouseover="window.status='Click here to export to excel file';return true" onmouseout="window.status='';return true">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" ALIGN="BOTTOM" BORDER="0"  width="53" height="17" title="Click here to export to excel file"/>
                            </chiptrack:restrictedLink>
                        </logic:equal>
                        <logic:equal name="reportType" value="<%=Constants.ACTION_DATA_DUMP_TRANSACTION_REPORT%>">
                            <%
                                String jsFunction = "javascript:exportToFile('"+Constants.ACTION_DATA_DUMP_TRANSACTION_REPORT+"')";
                            %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.TRANSACTION_DATA_DUMP_REPORT%>' action='<%=User.USER_ACTION_VIEW%>' href='<%=jsFunction%>' onmouseover="window.status='Click here to export to excel file';return true" onmouseout="window.status='';return true">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" ALIGN="BOTTOM" BORDER="0"  width="53" height="17" title="Click here to export to excel file"/>
                            </chiptrack:restrictedLink>
                        </logic:equal>
                        <logic:equal name="reportType" value="<%=Constants.ACTION_SORT_TRANSACTION_DATA_DUMP_REPORT%>">
                            <%
                                String jsFunction = "javascript:exportToFile('"+Constants.ACTION_SORT_TRANSACTION_DATA_DUMP_REPORT+"')";
                            %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.SORT_TRANSACTION_DATA_DUMP_REPORT%>' action='<%=User.USER_ACTION_VIEW%>' href='<%=jsFunction%>' onmouseover="window.status='Click here to export to excel file';return true" onmouseout="window.status='';return true">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" ALIGN="BOTTOM" BORDER="0"  width="53" height="17" title="Click here to export to excel file"/>
                            </chiptrack:restrictedLink>
                        </logic:equal>
                        <logic:equal name="reportType" value="<%=Constants.ACTION_ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT%>">
                            <%
                                String jsFunction = "javascript:exportToFile('"+Constants.ACTION_ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT+"')";
                            %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.ASSEMBLY_TRANSACTION_DATA_DUMP_REPORT%>' action='<%=User.USER_ACTION_VIEW%>' href='<%=jsFunction%>' onmouseover="window.status='Click here to export to excel file';return true" onmouseout="window.status='';return true">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" ALIGN="BOTTOM" BORDER="0"  width="53" height="17" title="Click here to export to excel file"/>
                            </chiptrack:restrictedLink>
                        </logic:equal>
                        &nbsp;<a href="javascript:dataDumpReportsForm.reset();" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"  title="Click here to Reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
                        </td>
                    </TABLE>
                </TD>
            </tr>
            <tr height="30"><td colspan="4">&nbsp;</td></tr>
        </TABLE>
    </html:form>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>